import request  from "@/utils/request.js";

const ROLE_PREFIX= "/admin/role"
export default {
    /**
     * 分页获取角色列表
     * @param page 当前页
     * @param size 每页数量
     * @returns {*}
     */
    getRolePageList(page,size){
        return request({
            method:'get',
            url:`${ROLE_PREFIX}/list/${page}/${size}`
        })
    },
    /**
     * 获取角色绑定的所有权限id
     * @param roleId
     * @returns {*}
     */
    getRoleBindPermissionIds(roleId){
        return request({
            method:"get",
            url:`${ROLE_PREFIX}/bindPermissionIds/${roleId}`
        })
    },
    getRoleInfoById(roleId){
        return request({
            method:'get',
            url:`${ROLE_PREFIX}/info/${roleId}`
        })
    },

    deleteRole(roleId){
        return request({
            method:'delete',
            url:`${ROLE_PREFIX}/delete/${roleId}`
        })
    },
    enableRole(roleId,isEnable){
        return request({
            method:'get',
            url:`${ROLE_PREFIX}/enable/${roleId}/${isEnable}`
        })
    },
    addRole(role){
        return request({
            method:'post',
            url:`${ROLE_PREFIX}/add`,
            data:role
        })
    },
    updateRole(role){
        return request({
            method:'post',
            url:`${ROLE_PREFIX}/update`,
            data:role
        })
    },
    bindRoleWithPermission(roleId,menuIds){
        return request({
            method:'post',
            url:`${ROLE_PREFIX}/bindPermission`,
            data:{
                roleId:roleId,
                permissionIds:menuIds
            }
        })
    },
    getAllRoles(){
        return request({
            method:'get',
            url:`${ROLE_PREFIX}/list/all`
        })
    },
    bindUserRole(dto){
        return request({
            method:'post',
            url:`${ROLE_PREFIX}/bindUser`,
            data:dto
        })
    }
}